package com.link2room.rodimus.controller.inside;


import com.link2room.common.dto.result.base.BaseResultDto;
import com.link2room.rodimus.facade.IExpressFacadeService;
import com.link2room.rodimus.dto.param.inside.ExpressFindInsideParamDto;
import com.link2room.rodimus.dto.param.inside.ExpressNewInsideParamDto;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * Created by LN on 2017/9/7.11:43
 */
@Api(tags = "发货相关")
@RestController
@RequestMapping("/in/Express")
public class ExpressInsideController {

    @Resource
    private IExpressFacadeService expressFacadeService;

    @RequestMapping(method = RequestMethod.POST)
    public BaseResultDto newExpress(@RequestBody ExpressNewInsideParamDto paramDto) throws Exception {

        BaseResultDto resDto = new BaseResultDto();
        resDto.setResultCode(0);
        resDto.setResultInfo(expressFacadeService.newInsideExpress(paramDto));
        return resDto;
    }


    @RequestMapping(method = RequestMethod.GET)
    public BaseResultDto newExpress(
            @RequestParam(value = "mobile",required = false) String mobile,
            @RequestParam(value = "sourceType",required = false) String sourceType,
            @RequestParam(value = "sourceNo",required = false) String sourceNo,
            @RequestParam(value = "expressNo",required = false) String expressNo,
            @RequestParam(value = "goodCode",required = false) String goodCode,
            @RequestParam(value = "isDelivered",required = false) String isDelivered,
            @RequestParam(value = "thirdExpressNo",required = false) String thirdExpressNo
    ) throws Exception {
        ExpressFindInsideParamDto paramDto = new ExpressFindInsideParamDto();
        paramDto.setMobile(mobile);
        paramDto.setSourceType(sourceType);
        paramDto.setSourceNo(sourceNo);
        paramDto.setExpressNo(expressNo);
        paramDto.setGoodCode(goodCode);
        paramDto.setIsDelivered(isDelivered);
        paramDto.setThirdExpressNo(thirdExpressNo);
        paramDto.setExpressNo(expressNo);
        BaseResultDto resDto = new BaseResultDto();
        resDto.setResultCode(0);
        resDto.setQueryResult(expressFacadeService.findExpressBaseDtos(paramDto));
        return resDto;
    }


}
